

package cn.shengchao.examstar.pay.model.aggregate;

import cn.shengchao.examstar.pay.model.entity.OrderEntity;
import cn.shengchao.examstar.pay.model.entity.ProductEntity;
import cn.shengchao.examstar.pay.model.valobj.OrderStatusVO;
import cn.shengchao.examstar.pay.utils.OrderNumberUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CreateOrderAggregate {

    // 用户ID
    private String userId;
    private String shareCode;
    // 商品实体对象
    private ProductEntity productEntity;
    // 订单实体对象
    private OrderEntity orderEntity;
    public static String buildOrderNewId() {
        return  "1330"+OrderNumberUtils.generatorOrderNumber();
    }
    public static OrderEntity buildOrderEntity(String productId, String productName, String productInfo) {
        return OrderEntity.builder()
            .productId(productId)
            .productName(productName)
            .orderId("1331"+OrderNumberUtils.generatorOrderNumber())
            .orderTime(new Date())
            .productInfo(productInfo)
            .orderStatus(OrderStatusVO.CREATE)
            .build();
    }

    public static OrderEntity buildOrderEntityForOrderId(String orderId,String productId, String productName, String productInfo) {
        return OrderEntity.builder()
                .productId(productId)
                .productName(productName)
                .orderId(orderId)
                .orderTime(new Date())
                .productInfo(productInfo)
                .orderStatus(OrderStatusVO.CREATE)
                .build();
    }

}
